package com.sikaryofficial.backend.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author : qinjinyuan
 * @desc : 活动类型枚举
 * @date : 2023/11/04 10:08
 */
@Getter
@AllArgsConstructor
public enum PrizeTypeEnum {

    // 奖品类型:1-虚拟礼品 2-实物礼品 3-谢谢惠顾
    /**
     * 1-purchase 抢购
     */
    VIRTUALLY(1, "虚拟礼品"),
    /**
     * 2-lottery 抽奖
     */
    PHYSICAL(2, "实物礼品"),

    /**
     * 3-auction 竞拍
     */
    THANK_YOU(3, "谢谢惠顾");

    private final Integer code;
    private final String name;

    public static PrizeTypeEnum getByCode(Integer code) {
        return Arrays.stream(PrizeTypeEnum.values())
                .filter(pointRuleEnum -> Objects.nonNull(code) && pointRuleEnum.getCode().equals(code))
                .findFirst().orElse(null);

    }

    public static String getNameByCode(Integer code) {
        PrizeTypeEnum prizeTypeEnum = getByCode(code);
        if (Objects.isNull(prizeTypeEnum)) {
            return "";
        }
        return prizeTypeEnum.getName();
    }

}
